<template>
  <div class="login-container">
    <el-form class="login-form" :model="user" ref="Form">
      <el-form-item class="login-head"> </el-form-item>
      <el-form-item>
        <el-input v-model="user.mobile" placeholder="请输入手机号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="user.code" placeholder="请输入验证码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-checkbox v-model="checked"
          >我已阅读并同意用户协议及隐私条款</el-checkbox
        >
      </el-form-item>
      <el-form-item>
        <el-button
          class="login-btn"
          type="primary"
          :loading="loginLoading"
          @click="onLogin"
          >登录</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from "@/utils/request";
export default {
  name: "LoginIndex",
  components: {},
  data() {
    return {
      user: {
        mobile: "",
        code: "",
      },
      checked: false,
      loginLoading: false,
    };
  },
  methods: {
    onLogin() {
      const user = this.user;
      this.loginLoading = true;
      request({
        method: "POST",
        url: "/mp/v1_0/authorizations",
        data: user,
      })
        .then((res) => {
          this.$message({
            message: "登录成功",
            type: "success",
          });
          this.loginLoading = false;
        })
        .catch((err) => {
          this.$message({
            message: "登陆失败",
            type: "error",
          });
          this.loginLoading = false;
        });
    },
  },
};
</script>

<style lang="less" scoped>
.login-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: url("./login_bg.jpg") no-repeat;
  background-size: cover;
  .login-head {
    background: url("./logo_index.png") no-repeat;
    height: 57px;
    width: 100%;
  }
  .login-form {
    background-color: #fff;
    padding: 50px;
    min-width: 300px;
    .login-btn {
      width: 100%;
    }
  }
}
</style>